package com.x.mvp.widget.cycleview;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.x.mvp.R;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;


public class ViewFactory {

    public static ImageView getImageView(Context context, String url) {
        ImageView imageView = (ImageView) LayoutInflater.from(context).inflate(
                R.layout.view_banner, null);
        Glide.with(context).load(url).apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade()).into(imageView);
        return imageView;
    }

    public static ImageView getCircleImageView(Context context, String url) {
        ImageView imageView = (ImageView) LayoutInflater.from(context).inflate(
                R.layout.view_banner, null);
        Glide.with(context).load(url).apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade()).into(imageView);
        return imageView;
    }

    public static ImageView getRoundRectImageView(Context context, String url) {
        ImageView imageView = (ImageView) LayoutInflater.from(context).inflate(
                R.layout.view_banner, null);
        Glide.with(context).load(url).apply(new RequestOptions().centerCrop())
                .transition(DrawableTransitionOptions.withCrossFade()).into(imageView);
        return imageView;
    }
}